#!/bin/sh

##########################
HOME_NAME=huangjunjia
STORAGE_LOCATION=/home/$HOME_NAME/code/open-webui-docker
DOCKER_NAME=open-webui
##########################
# 这里加777权限是必要的
echo "本地路径 $STORAGE_LOCATION"

# check
if [[ -n $(docker ps -q -f "name=${DOCKER_NAME}") ]];then
        echo "not exist docker name=${DOCKER_NAME}"
else
    echo "exist docker name=${DOCKER_NAME}. neet exit, then rm docker."
    docker rm ${DOCKER_NAME}
fi

# run
# # 使用 Docker 安装 Open WebUI（仅 API 模式）
# docker run -d -p 3000:8080 -e OPENAI_API_KEY=your_secret_key -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main
docker run -d \
-p 29544:8080 \
-e OPENAI_API_KEY=your_secret_key \
-v $DOCKER_NAME:/app/backend/data \
--name $DOCKER_NAME \
--restart always \
ghcr.io/open-webui/open-webui:main

# logs
docker logs -f $DOCKER_NAME

